<?php
// @formatter:off
/**
 * @file p.frontview.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-05-04 01:33:52 +0000 (Sun, 04 May 2014) $
 *
 * $Id: p.frontview.php 111 2014-05-04 01:33:52Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/tools/p.frontview.php $
 */
require_once __DIR__."/config.php";
(!$wcWebToolsEnabled) && die("Web tools are disabled\n");

define('__INDEX__', true);

require_once dirname(__DIR__).'/config/config.php';
global $wcPaths;
require_once $wcPaths["mvc"]["config"];

if(defined("WC_NOT_INSTALLED")) {
	header("Location: ../");
} else {
	$actions = array();

	$dir = new RecursiveDirectoryIterator($wcPaths["mvc"]["actions"]);
	$dirIterator = new RecursiveIteratorIterator($dir);
	$regexIterator = new RegexIterator($dirIterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

	foreach($regexIterator as $filename => $cur) {
		$actions[$filename] = str_replace("{$wcPaths["mvc"]["actions"]}/", "", $filename);
	}
	asort($actions);

	$layouts = array();

	$dir = new RecursiveDirectoryIterator($wcPaths["mvc"]["layouts"]);
	$dirIterator = new RecursiveIteratorIterator($dir);
	$regexIterator = new RegexIterator($dirIterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

	foreach($regexIterator as $filename => $cur) {
		$layouts[$filename] = str_replace("{$wcPaths["mvc"]["layouts"]}/", "", $filename);
	}
	asort($layouts);
	?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>FrontView</title>

		<script type="text/javascript" src="../includes/jquery/<?php echo $wcVersions["jquery"]; ?>/jquery-<?php echo $wcVersions["jquery"]; ?>.min.js"></script>
		<script type="text/javascript" src="../install/install.js"></script>

		<link rel="stylesheet" type="text/css" href="../install/install.css"/>
	</head>
	<body>
		<span class="PageTitle">FrontView</span>
		<div class="Section">
			<span class="Title">Actions</span>
			<div class="Paragraph">
				<ul>
<?php	foreach($actions as $filename => $action) {	?>
					<li title="<?php echo $filename; ?>"><?php echo $action; ?></li>
<?php	}	?>
				</ul>
			</div>
		</div>
		<div class="Section">
			<span class="Title">Layouts</span>
			<div class="Paragraph">
				<ul>
<?php	foreach($layouts as $filename => $layout) {	?>
					<li title="<?php echo $filename; ?>"><?php echo $layout; ?></li>
<?php	}	?>
				</ul>
			</div>
		</div>
	</body>
</html>
	<?php
}
?>
